#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#include "CuTest.h"

#include "test_sprout.h"
#include "sprout_util.h"

int main(void)
{
    CuString *output = CuStringNew();
    CuSuite *suite = CuSuiteNew();
    CuSuiteAddSuite(suite, test_util_suite());
    CuSuiteAddSuite(suite, test_object_suite());
    CuSuiteAddSuite(suite, test_array_suite());
    CuSuiteAddSuite(suite, test_string_suite());
    CuSuiteRun(suite);
    CuSuiteSummary(suite, output);
    CuSuiteDetails(suite, output);
    printf("%s\n", output->buffer);
}

char *read_file(const char *filename)
{
    FILE *file = fopen(filename, "r");
    fseek(file, 0L, SEEK_END);
    long file_size = ftell(file);
    rewind(file);
    size_t sz = file_size + 1;
    void *result = allocate_memory(sz);
    fread(result, 1, file_size, file);
    fclose(file);
    return result;
}
